<?php
require_once(dirname(__FILE__).'/../../../../local/smb_connection.php');

function show_results($results) {
?>
<table cellspacing="12">
<tr><th>Parent folder</th><th>Filename</th><th>Size</th><th>Date</th><th>Folder</th><th>Hidden</th></tr>
<?php
foreach($results as $result) {
?>
<tr>
<td><?= htmlspecialchars($result->parentfolder) ?></td>
<td><?= htmlspecialchars($result->filename) ?></td>
<td><?= $result->size ?></td>
<td><?= date('r',$result->timestamp) ?></td>
<td><?= $result->isfolder ? 'y' : '&nbsp;' ?></td>
<td><?= $result->ishidden ? 'y' : '&nbsp;' ?></td>
</tr>
<?php
}
?>
</table>
<?php
}

$smb=new smb_connection(
    '//panther/strucauth$',
    $CFG->systemwindowsuser,$CFG->systemwindowspassword,'OPEN-UNIVERSITY',true);
$smb->cd('vlepreview');
$everything=$smb->recursive_dir();
show_results($everything);   
$smb->delete('test.txt'); 



/*    
$smb=new smb_connection(
    '//esaki/LTS-eBooks',
    $CFG->systemwindowsuser,$CFG->systemwindowspassword,'OPEN-UNIVERSITY',false);
    
$smb->cd('e-book_2004_production');
$before=time();
$everything=$smb->recursive_dir();
$delay=time()-$before;
echo "<p>Obtained list after $delay seconds."; 
show_results($everything);    
*/    
    
/*        
echo '<h1>Root</h1>';
show_results($smb->dir());
echo '<h1>eb production</h1>';
$smb->cd('e-book_2004_production');
show_results($smb->dir());
echo '<h1>Get file</h1>';
$speed=$smb->get('Set Books - Folder List.doc',dirname(__FILE__).'/../../../../../moodledata/test.doc');
print "<p>Download speed $speed KB/s</p>";*/ 
$smb=null;
?>
